package com.ziyun.pop.mall.module.order.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import com.pay.api.AlipayService;
import com.pay.api.UmfpayService;
import com.pay.api.UnionpayService;
import com.pay.api.WeixinpayService;

/**
 * 
 * 
 * @author lvai
 * 
 */

@Controller
public class OrderPayBackController {

	private static Logger _log = LoggerFactory.getLogger(OrderPayBackController.class);

	@Autowired
	private AlipayService alipayService;

	@Autowired
	private WeixinpayService weixinpayService;

	@Autowired
	private UnionpayService unionpayService;

	@Autowired
	private UmfpayService umfPayService;

	/**
	 * aliyun支付回调
	 * 
	 * @param request
	 * @param response
	 */
	@PostMapping("/order/aliPayCallback")
	public void aliPayCallback(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("开始支付！");
		alipayService.aliPayCallback(request, response);
		System.out.println("支付宝支付成功！");
	}

	/**
	 * weixin支付回调
	 * 
	 * @param request
	 * @param response
	 */
	@PostMapping("/order/weixinpayCallback")
	public void weixinpayCallback(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("开始支付！");
		weixinpayService.weixinpayCallback(request, response);
		System.out.println("微信支付成功！");
	}

	/**
	 * 银联支付回调
	 * 
	 * @param request
	 * @param response
	 */
	@PostMapping("/order/unionPayCallback")
	public void unionPayCallback(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("开始支付！");
		unionpayService.unionPayCallback(request, response);
		System.out.println("银联支付成功！");
	}

	/**
	 * 联动支付回调
	 * 
	 * @param request
	 * @param response
	 */
	@GetMapping("/order/umfPayRecall")
	public void umfPayRecall(HttpServletRequest request, HttpServletResponse response) throws Exception {
		System.out.println("开始支付！");
		umfPayService.umfPayRecall(request, response);
		System.out.println("联动支付成功！");
	}

}
